package mypackage.ui;

import java.util.Vector;

import net.rim.device.api.ui.component.CheckboxField;
import net.rim.device.api.ui.container.VerticalFieldManager;

public class LookupList extends VerticalFieldManager {

	Vector items;

	public LookupList() {
		super();
		items = new Vector();
	}

	public void addItem(String str, boolean isChecked) {
		items.addElement(str);
		CheckboxField checkboxField = new CheckboxField(str, isChecked);
		add(checkboxField);
	}

	public void removeItem(int index) {
		removeItem(index);
		items.removeElementAt(index);
	}

	public void addAll(Vector v) {
		for (int i = 0; i < v.size(); i++)
			addItem(v.elementAt(i).toString(), false);
	}
	
	public void lookUp(String string) {
		deleteAll();
		for(int i=0;i<items.size();i++)
			if(items.elementAt(i).toString().startsWith(string))
				add(new CheckboxField(items.elementAt(i).toString(),false));
		
	}
}
